<?php

namespace app\index\controller;

use think\Controller;
use think\Request;
use app\common\model\Album;
use think\Db;

class AlbumController extends Controller
{
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {
        $list = Album::where('status',1)->select()->toArray();
        if(!$list){
            $this->error('没有相册','/');
        }
        if(count($list) > 1){
            $num = intval(floor(count($list)/2));
        }else{
            $num =1;
        }
        $list = array_chunk($list,$num);
        $list['num'] =count($list);
        $this->assign('list',$list);
        return view();
    }

    public function detail($id){
        $id = intval($id);
        $album = Db::table('yu_album_detail a')->join('yu_file_infos f','f.id = a.f_id')->where('a_id', $id)->select();
        $this->assign('list',$album);
        return view();
    }

}
